<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="utf-8">
    <title></title>
    <meta name="renderer" content="webkit">
    <meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
    <meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1">
    <meta name="viewport"
          content="width=device-width, initial-scale=1.0, minimum-scale=1.0, maximum-scale=1.0, user-scalable=0">
    <link rel="stylesheet" href="layuiadmin/layui/css/layui.css" media="all">
    <link rel="stylesheet" href="layuiadmin/style/admin.css" media="all">
</head>
<body>
    <fieldset class="layui-elem-field layui-field-title" style="margin-top: 20px;">
        <legend>录入联系人</legend>
    </fieldset>
    <form id="myform" class="layui-form" action="">
        <input type="hidden" id="personId" name="personId" autocomplete="off" class="layui-input">
        <div class="layui-form-item">
            <label class="layui-form-label">联系人名称</label>
            <div class="layui-input-block">
                <input type="text" id="personName" name="personName" lay-verify="required" lay-reqtext="联系人姓名是必填项." placeholder="请输入" autocomplete="off" class="layui-input">
            </div>
            <label class="layui-form-label">联系人电话</label>
            <div class="layui-input-block">
                <input type="text" id="phone" name="phone" lay-verify="required" lay-reqtext="联系人电话是必填项" placeholder="请输入" autocomplete="off" class="layui-input">
            </div>
            <div class="layui-form-item">
                <label class="layui-form-label">主联系人与否</label>
                <div id="bidderYN" class="layui-input-block">
                    <input type="radio" name="bidderYN" value="Y" title="是" checked="">
                    <input type="radio" name="bidderYN" value="N" title="否">
                </div>
            </div>
            <div class="layui-form-item layui-form-text">
                <label class="layui-form-label">备注</label>
                <div class="layui-input-block">
                    <textarea id="description" name="description" placeholder="请输入内容" class="layui-textarea"></textarea>
                </div>
            </div>
            <div class="layui-form-item">
                <div class="layui-input-block">
                    <button type="submit" class="layui-btn" lay-submit="" lay-filter="formDemo">立即提交</button>
                    <button type="reset" class="layui-btn layui-btn-primary">重置</button>
                </div>
            </div>
        </div>
        <script src="layuiadmin/layui/layui.js"></script>
        <script>
            layui.use('form', function(){
                var form = layui.form;
                var $ = layui.$;
                form.on('submit(formDemo)', function (data) {
                    console.log(JSON.stringify(data.field));
                    $.ajax({
                        url:'http://localhost:8086/updateContact',
                        data: data.field,
                        type: "post",
                        dataType: "json",
                        async:'false',
                        success: function (data) {
                            console.log(data);
                            window.parent.location.reload();
                            parent.layer.closeAll();
                        },
                        error:function(data){
                            $.messager.alert('错误',data.msg);
                        }
                    });
                })
                form.render();
            });
        </script>
    </form>
</body>
</html>